/**字典数据读取与翻译(格式化) */
import Vue from "vue";
import { USER } from "@/common/Constant";
import moment from "moment";
function getItemValue(typeCode, val) {
  let item = Vue.ls.get(USER).dicts[typeCode].filter(item => item.value == val)
  if (item.length == 0) return val
  return item[0].text
}
export const getDict = (typeCode) => Vue.ls.get(USER).dicts[typeCode];//按字典类取字典数据

export const genderFormat = (row, column) => getItemValue('gender', row[column.property]);//性别
export const statusFormat = (row, column) => getItemValue('status', row[column.property]);//状态
export const deptTypeFormat = (row, column) => getItemValue('deptType', row[column.property]);//机构类型
export const requestTypeFormat = (row, column) => getItemValue('requestType', row[column.property]);//请求类型

export const dateFormat = (row, column) => { //时间格式化
  var date = row[column.property];
  if (date == undefined) return "";
  return moment(date).format("YYYY-MM-DD HH:mm:ss");
};